﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Management.Automation;

using ESF.MUP.BasePlatform;
using ESF.MUP.BasePlatform.Domain.Model;
//using ESF.MUP.BasePlatform.DbService;
//using ESF.MUP.BasePlatform.DbService.MSSQL;

namespace ESF.MUP.Powershell
{
    [Cmdlet(VerbsCommon.Get, "Application")]
    public class GetApplication:BaseCmdlet
    {

        [Parameter(Mandatory=false)]
        public String Name { get; set; }


        protected override void ProcessRecord()
        {
            //IApplicationService appSvc = MiddlewareManagementService.Current.GetApplicationService();

            //if (String.IsNullOrEmpty(this.Name))
            //{
            //    this.WriteObject(appSvc.GetAll());
            //}
            //else
            //{
            //    this.WriteObject(appSvc.GetByName(this.Name));
            //}


            ESF.MUP.BasePlatform.ApplicationServices.Interfaces.IApplicationManagementService svcApp  = MiddlewareManagementService.Current.GetApplicationService();
            svcApp.GetByName(this.Name);

            try
            {
                //WriteObject(repo.GetAll().ToList());
                svcApp.Add(new Application() { Name = "ygo" });
            }
            catch(Exception ex)
            {
                WriteError(new ErrorRecord(ex,"1", ErrorCategory.InvalidOperation, null));
            }

        }

    }
}
